/*
 * Instruction58.java
 *
 * Created on March 22, 2007, 8:57 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package moto9s12sim;

/**
 *
 * @author Fergus Earnshaw
 */
public class Instruction58 extends Instruction{
    
    /** Creates a new instance of Instruction58 */
    public Instruction58() {
    
        this.strAssemblyCode = "ASLB/LSLB";
        this.bCodes = new byte[1];
        this.bCodes[0] = (byte)Integer.parseInt("58",16);
    }
    
    public boolean excute(M9S12 cpu)
    {
        this.shAddr = cpu.PC.getRegister();
        cpu.PC.inc();
        
        //TO DO CODE INSTRUCTION
        //to LS MULT BY 2 then check with subtraction of msb +1...
        
        short shTmp;
        
        shTmp = (short)(cpu.B.getRegister()*2);
        
        if(shTmp > 255)
        {
            cpu.CC.setC(true);
            cpu.CC.setV(true);
            shTmp =-256;
        }
        
        cpu.A.setRegister((byte)shTmp);
        cpu.CC.setZ((cpu.B.getRegister() == 0)?true:false);
        
        
        //to do set flags        
        //cpu.CC.setN();
        
        
        printInstruction(cpu);
        //I think the first invalid instruction should halt excution
        return true;
    }  
    
}

    

